# build stage
FROM node:16.18.1 as build-stage
WORKDIR /app
COPY package.json .npmrc ./
RUN npm install --registry=https://registry.npmmirror.com
COPY . .
RUN npm run build:prod

# production stage
# 选择 nginx:1.23.2，目前的mainline版本，指定版本号避免意外变动
FROM nginx:1.23.2 as production-stage
COPY --from=build-stage /app/dist /usr/share/nginx/html
COPY --from=build-stage /app/deploy/nginx/default.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
